#include "DblStack.h"

void initStack(DblStack& DS)
{
	DS.bot[0] = DS.top[0] = -1;
	DS.bot[1] = DS.top[1] = m;
}

bool Push(DblStack& DS, SElemType x, int d)
{
	if (DS.top[0] + 1 == DS.top[1] || d != 0 && d != 1)
	{
		return false;
	}
	if (d == 0)
	{
		DS.top[0]++;
	}
	else
	{
		DS.top[1]--;
	}
	DS.V[DS.top[d]] = x;
	return true;
}

bool Pop(DblStack& DS, SElemType& x, int d)
{
	if (d != 0 && d != 1 || DS.top[d] == DS.bot[d])
	{
		return false;
	}
	x = DS.V[DS.top[d]];
	if (d == 0)
	{
		DS.top[0]--;
	}
	else
	{
		DS.top[1]++;
	}
	return true;
}